package com.it.xuehang.mapper;

import com.it.xuehang.entity.YesterdayWeather;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * <p>
 * 昨天天气信息表 Mapper 接口
 * </p>
 *
 * @author xuehang
 * @since 2024-12-12
 */
public interface YesterdayWeatherMapper extends BaseMapper<YesterdayWeather> {

    // 自定义查询：检查是否已存在相同日期和城市ID的数据
    @Select("SELECT COUNT(*) FROM yesterday_weather WHERE city_id = #{cityId} AND date = #{date}")
    int existsByCityIdAndDate(@Param("cityId") BigDecimal cityId,@Param("date") LocalDate date);


}
